package com.example.figurehecheng.controller.user;

import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.vo.SceneryDetailVO;
import com.example.figurehecheng.domain.vo.SceneryVO;
import com.example.figurehecheng.service.ISceneryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 景点表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-04
 */
@RestController("userSceneryController")
@RequestMapping("/user/scenery")
@Api(tags = "用户端-景点相关接口")
@RequiredArgsConstructor
public class SceneryController {

    private final ISceneryService sceneryService;
    /**
     * 查询景点列表
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询景点列表")
    public Result<List<SceneryVO>> listScenery() {
        List<SceneryVO> list = sceneryService.querySceneryList();
        return Result.success(list);
    }
    /**
     * 查询景点详情
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("查询景点详情")
    public Result<SceneryDetailVO> getSceneryDetail(@PathVariable("id") Long id) {
        SceneryDetailVO detail = sceneryService.getSceneryDetail(id);
        return Result.success(detail);
    }
    /**
     * 根据名称搜索景点
     * @return
     */
    @GetMapping("/searchByName")
    @ApiOperation("根据名称搜索景点")
    public Result<List<SceneryVO>> searchSceneryListByName(@RequestParam("name") String name){
        List<SceneryVO> sceneryVOList=sceneryService.getSceneryListByName(name);
        return Result.success(sceneryVOList);
    }
}





